package com.zbfmq.rabbitConfirm;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/11  9:39
 * 描述:
 */
@Component
public class MyRabbitConfirm implements RabbitTemplate.ConfirmCallback {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void initRebbit(){
        rabbitTemplate.setConfirmCallback(this);
    }

    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {
        //System.out.println("-------附加消息---"+correlationData.getId());
        System.out.println("-----exception-------->"+s);
        if(b){
            System.out.println("========》消息到达交换机");
        }else {
            System.out.println("========》消息么有到达交换机");
        }

    }
}
